import request from '../utils/request'

export const queryPrivileges = (params) => {
  return request({
    method: 'GET',
    url: `idm-app/rest/admin/privileges`,
    params: params
  })
}

export const queryPrivilegeUsers = (params) => {
  return request({
    method: 'GET',
    url: `idm-app/rest/admin/privileges/${params.privilegeId}`,
    params: params
  })
}

export const createPrivilegeUser = ({ privilegeId, ...data }) => {
  return request({
    method: 'POST',
    url: `idm-app/rest/admin/privileges/${privilegeId}/users`,
    data: data
  })
}

export const deletePrivilegeUser = ({ privilegeId, userId }) => {
  return request({
    method: 'DELETE',
    url: `idm-app/rest/admin/privileges/${privilegeId}/users/${userId}`
  })
}

export const createPrivilegeGroup = ({ privilegeId, ...data }) => {
  return request({
    method: 'POST',
    url: `idm-app/rest/admin/privileges/${privilegeId}/groups`,
    data: data
  })
}

export const deletePrivilegeGroup = ({ privilegeId, groupId }) => {
  return request({
    method: 'DELETE',
    url: `idm-app/rest/admin/privileges/${privilegeId}/groups/${groupId}`
  })
}